﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPIS.GERP.GBMS.IBLL;
using KPIS.GERP.GBMS.MODEL;
using KPIS.GERP.GBMS.DAL;
using KPIS.GERP.GBMS.DAL;
using KPIS.GERP.GBMS.DALFactory;

namespace KPIS.GERP.GBMS.BLL
{
    public sealed class ProjectRequestOptionBLL : IProjectOptionBLL
    {
        private static readonly IProjectRequestOptionDAL dal = DataAccess.CreateProjectOption();
        private IProjectRequestOptionDAL prjDAL =  new ProjectRequestOptionDAL();

        public void Insert(string code, string name, string descr, string monthstart, string monthend, string reason, string objects, string target, string plan, string detail, string remark, string strategy, string jobsite, string year)
        {
            //ProjectInfo pjInfo = new ProjectInfo(0, code, name, descr, DateTime.Today, monthstart, monthend, reason, objects, target, plan, detail, remark, strategy, jobsite, Convert.ToInt32(year), "", new UserRecordInfo(1, null));

            //if (dal.Insert(pjInfo) > 0)
            //{

            //}
            //else
            //{

            //}
        }

        public void Update(string seq, string code, string name, string descr, string monthstart, string monthend, string reason, string objects, string target, string plan, string detail, string remark, string strategy, string jobsite, string year)
        {
            //ProjectInfo pjInfo = new ProjectInfo(Convert.ToInt32(seq), code, name, descr, DateTime.Today, monthstart, monthend, reason, objects, target, plan, detail, remark, strategy, jobsite, Convert.ToInt32(year), "", new UserRecordInfo(null, 1));

            //if (dal.Update(pjInfo) > 0)
            //{

            //}
            //else
            //{

            //}
        }

        public void Delete(string seq)
        {
            //if (dal.Delete(Convert.ToInt32(seq)) > 0)
            //{

            //}
            //else
            //{

            //}
        }

        public IList<ProjectOptionInfo> Search(string seq, string pjseq, OptionType optionType)
        {
            ProjectOptionInfo info = new ProjectOptionInfo();

            IOptionTypeBLL optTypeCtrl = new OptionTypeBLL();

            int inOptionType = optTypeCtrl.MappingOptionTypeEnum(optionType);
            int inSeq = (seq.Length > 0) ? Convert.ToInt32(seq) : 0;
            int inProjectSeq = (pjseq.Length > 0) ? Convert.ToInt32(pjseq) : 0;

            OptionInfo opt = new OptionInfo();
            opt.Type = inOptionType;

            ProjectInfo pj = new ProjectInfo();
            pj.Sequence = inProjectSeq;

            info.Sequence = inSeq;
            info.Option = opt;
            info.Project = pj;

            return prjDAL.Search(info);
        }
    }
}
